package com.huawang.mdesign.model.service.util.reqif;

import com.huawang.mdesign.model.service.util.reqif.ref.SpecObjectRef;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * Represents a node in a hierarchically structured requirements specification.
 *
 * @author xdl
 * @since 2023-04-04
 */
@Getter
@Setter
@XStreamAlias(ReqIFConstants.SPEC_HIERARCHY)
public class SpecHierarchy extends AbstractAccessControlledElement {

    /**
     * Some requirements authoring tools enable the user to use tables as part of a requirement’s content, where parts of
     * the table represent requirements as well. If that is the case, this attribute needs to be set to true for the root node of
     * the table hierarchy and all descendant SpecHierarchy nodes.
     */
    @XStreamAlias(ReqIFConstants.IS_TABLE_INTERNAL)
    @XStreamAsAttribute
    private Boolean isTableInternal;

    /**
     * Up link to previous level of SpecHierarchy (which owns this level).
     */
    @XStreamOmitField
    private SpecHierarchy parent;

    /**
     * Up link to specification hierarchy root (which may own this level).
     */
    @XStreamOmitField
    private Specification root;

    /**
     * Down links to next level of owned SpecHierarchy.
     */
    @XStreamAlias(ReqIFConstants.CHILDREN)
    private List<SpecHierarchy> children = new ArrayList<>();

    /**
     * The attributes whose values are editable for the SpecHierarchy by a tool user.
     */
    @XStreamOmitField
    private List<AbstractAttributeDefinition> editableAtts = new ArrayList<>();

    @XStreamAlias(ReqIFConstants.EDITABLE_ATTS)
    private List<LocalRef> editableAttRefs = new ArrayList<>();

    /**
     * Pointer to the associated SpecObject.
     */
    @XStreamOmitField
    private SpecObject object;

    @XStreamAlias(ReqIFConstants.OBJECT)
    private SpecObjectRef objectRef;
}
